/* GUI CONVERTED from resrqrin.p (converter v1.76) Wed May 22 11:22:55 2002 */
/* resrqrin.p - REPETITIVE - Gets scrap/reject quantites from user            */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.5.1.3 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3               LAST MODIFIED: 10/31/94   BY: WUG *GN77*       */
/*                                            02/28/95   by: srk *G0FZ*       */
/* REVISION: 7.3      LAST MODIFIED: 05/16/96   BY: *G1VG* Julie Milligan     */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 09/11/00   BY: *N0RS* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.5.1.3 $   BY: Jean Miller        DATE: 05/21/02  ECO: *P05V*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* GETS SCRAP/REJECT QUANTITIES FROM THE USER                                 */
/* PUTS UP AN ARRAY OF 10 QUANTITIES AND REASONS IN AN OVERLAY PANEL          */

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input  parameter reason_type as character.
define input  parameter title_caption as character.
define output parameter undo_stat like mfc_logical no-undo.

define new shared variable global_rsntyp as character.

define shared variable rsn_codes as character extent 10.
define shared variable quantities like wr_qty_comp extent 10.

define variable i as integer.
define variable valmsg as character.
define variable msg_ct as integer.
define variable disp-quantity    as character no-undo format "x(16)".
define variable disp-reason-code as character no-undo format "x(15)".

/* Not a valid value */
{pxmsg.i &MSGNUM=4291 &ERRORLEVEL=3 &MSGBUFFER=valmsg}

disp-quantity = getTermLabelRt("QUANTITY",16).
disp-reason-code = getTermLabel("REASON_CODE",15).

/*DISPLAY FRAME Q*/
FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
disp-quantity    to 16 no-label
   disp-reason-code at 19 no-label
   skip
   quantities[1] at 5  validate(quantities[1] <> ?,valmsg)
   rsn_codes[1]        validate(rsn_codes[1] <> ?,valmsg)
   skip
   quantities[2] at 5  validate(quantities[2] <> ?,valmsg)
   rsn_codes[2]        validate(rsn_codes[2] <> ?,valmsg)
   skip
   quantities[3] at 5  validate(quantities[3] <> ?,valmsg)
   rsn_codes[3]        validate(rsn_codes[3] <> ?,valmsg)
   skip
   quantities[4] at 5  validate(quantities[4] <> ?,valmsg)
   rsn_codes[4]        validate(rsn_codes[4] <> ?,valmsg)
   skip
   quantities[5] at 5  validate(quantities[5] <> ?,valmsg)
   rsn_codes[5]        validate(rsn_codes[5] <> ?,valmsg)
   skip
   quantities[6] at 5  validate(quantities[6] <> ?,valmsg)
   rsn_codes[6]        validate(rsn_codes[6] <> ?,valmsg)
   skip
   quantities[7] at 5  validate(quantities[7] <> ?,valmsg)
   rsn_codes[7]        validate(rsn_codes[7] <> ?,valmsg)
   skip
   quantities[8] at 5  validate(quantities[8] <> ?,valmsg)
   rsn_codes[8]        validate(rsn_codes[8] <> ?,valmsg)
   skip
   quantities[9] at 5  validate(quantities[9] <> ?,valmsg)
   rsn_codes[9]        validate(rsn_codes[9] <> ?,valmsg)
   skip
   quantities[10] at 5 validate(quantities[10] <> ?,valmsg)
   rsn_codes[10]       validate(rsn_codes[10] <> ?,valmsg)
   skip
 SKIP(.4)  /*GUI*/
with frame q no-labels
 attr-space
width 40 overlay row 4 column 40 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-q-title AS CHARACTER.
 F-q-title = title_caption.
 RECT-FRAME-LABEL:SCREEN-VALUE in frame q = F-q-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame q =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame q + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame q =
  FRAME q:HEIGHT-PIXELS - RECT-FRAME:Y in frame q - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME q = FRAME q:WIDTH-CHARS - .5. /*GUI*/


undo_stat = yes.
global_rsntyp = reason_type.

pause 0.

/*DISPLAY REWRITTEN FROM ABOVE*/
display
   disp-quantity
   disp-reason-code
   quantities[1]
   rsn_codes[1]
   quantities[2]
   rsn_codes[2]
   quantities[3]
   rsn_codes[3]
   quantities[4]
   rsn_codes[4]
   quantities[5]
   rsn_codes[5]
   quantities[6]
   rsn_codes[6]
   quantities[7]
   rsn_codes[7]
   quantities[8]
   rsn_codes[8]
   quantities[9]
   rsn_codes[9]
   quantities[10]
   rsn_codes[10]
with frame q.

pause before-hide.

main:
do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


   set
      quantities[1]
      rsn_codes[1]
      quantities[2]
      rsn_codes[2]
      quantities[3]
      rsn_codes[3]
      quantities[4]
      rsn_codes[4]
      quantities[5]
      rsn_codes[5]
      quantities[6]
      rsn_codes[6]
      quantities[7]
      rsn_codes[7]
      quantities[8]
      rsn_codes[8]
      quantities[9]
      rsn_codes[9]
      quantities[10]
      rsn_codes[10]
   with frame q
   editing:

      if frame-field = "rsn_codes" then do:
         {mfnp05.i rsn_ref rsn_type "rsn_type = reason_type"
            rsn_code "input rsn_codes[frame-index]"}
         if recno <> ? then
         display rsn_code @ rsn_codes[frame-index]
         with frame q.
      end.
      else do:
         ststatus = stline[3].
         status input ststatus.
         readkey.
         apply lastkey.
      end.

   end.

   msg_ct = 0.

   do i = 1 to 10:

      if rsn_codes[i] <> "" then do:

         find rsn_ref where rsn_code = rsn_codes[i]
                        and rsn_type = reason_type
         no-lock no-error.

         if not available rsn_ref then do:
            /* Invalid Reason code */
            {pxmsg.i &MSGNUM=655 &ERRORLEVEL=2 &MSGARG1=rsn_codes[i]}
            msg_ct = msg_ct + 1.
         end.

      end.

   end.

   if msg_ct > 0 then do:
      message.
      if msg_ct modulo 2 = 1 then message.
   end.

   undo_stat = no.

end.
/*GUI*/ if global-beam-me-up then undo, leave.


hide no-pause.
